package com.icss.train_sys_back.mapper.ticket_manage;

import com.icss.train_sys_back.entity.ticket_manage.RefundTicketEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author 小泽
 * @createTime 2025/10/7 17:35
 */
@Mapper
public interface RefundTicketManageMapper {
    //退票记录分页+条件查询
    List<RefundTicketEntity> getListConditions(String refundId, String orderId, String username, Integer status);

    //退票审核通过处理
    @Update("update t_refund_ticket set  status = #{updateStatus} , process_time = now() where refund_id = #{refundId}")
    void updateStatus(String refundId, Integer updateStatus);

    //退票审核拒绝退票处理
    @Update("update t_refund_ticket set  status = 3 , process_time = now(),remark = #{remark} where refund_id = #{refundId}")
    void updateStatusReject(String refundId, String remark);

    //插入退票记录
    @Insert("INSERT INTO t_refund_ticket (refund_id, order_id, ticket_id, user_id, username, train_number, " +
            "start_station, end_station, original_price, refund_amount, apply_time, status, reason) " +
            "VALUES (#{refundId}, #{orderId}, #{ticketId}, #{userId}, #{username}, #{trainNumber}, " +
            "#{startStation}, #{endStation}, #{originalPrice}, #{refundAmount}, #{applyTime}, #{status}, #{reason})")
    void insertRefundTicket(RefundTicketEntity refundTicketEntity);
}
